import { DomEditor } from '@wangeditor/editor'

export default function inlineVoid(editor) {
  const { isInline, isVoid } = editor
  const newEditor = editor

  // 重写 isInline
  newEditor.isInline = (elem) => {
    const type = DomEditor.getNodeType(elem)
    if (type === 'formula') {
      return true
    }

    return isInline(elem)
  }

  // 重写 isVoid
  newEditor.isVoid = (elem) => {
    const type = DomEditor.getNodeType(elem)
    if (type === 'formula') {
      return true
    }
    return isVoid(elem)
  }

  return newEditor
}
